package org.gap.wizards.world.actions;

import org.gap.wizards.items.Item;
import org.gap.wizards.pc.PlayerCharacter;
import org.gap.wizards.views.InventorySelectionView;
import org.gap.wizards.views.MessageOutput;
import org.gap.wizards.world.Location;
import org.gap.wizards.world.WorldAction;

public class DropItemAction implements WorldAction {
	private final PlayerCharacter pc;
	private final Location map;
	private final MessageOutput output;
	private final InventorySelectionView selection;

	public DropItemAction(PlayerCharacter pc, MessageOutput output, Location activeMap, InventorySelectionView selection) {
		this.pc = pc;
		this.output = output;
		this.map = activeMap;
		this.selection = selection;
	}

	@Override
	public void perform() {
		output.addMessage("Select an item to drop?");
		selection.setItems(pc.getInventory().allItems());

		for (Item each : selection.getSelection()) {
			pc.getInventory().removeItem(each);
			map.addItem(each);
		}
	}
}
